<div id="notification" class="notification error" style="display: none"></div>
<!-- Horizontal form (default) -->
<form class="horizontal-form" id="frmUser">

  <div style="margin-bottom: 20px;">
<!--    <p>
      <label><?php //echo $form['ref_number']->renderLabel() ?></label>
      <?php //echo $form['ref_number']->render() ?>
    </p>-->
    <p>
      <label><?php echo $form['status']->renderLabel() ?></label>
      <?php echo $form['status']->render() ?>
    </p>
    <?php echo $form->renderHiddenFields() ?>
  </div>

				<div class="form-tabs">

          <!-- Wizard -->
					<!-- Wizard Steps -->
					<ol class="wizard-steps">
              <li><a id="form-part1" class="current" href="javascript:void(0)">Company Information</a></li>
              <li><a id="form-part2" href="javascript:void(0)">Billing Instructions</a></li>
              <li><a id="form-part3" href="javascript:void(0)">Assignee List</a></li>
              <li><a id="form-part4" href="javascript:void(0)">Bulk Service Application</a></li>
					</ol>
					<!-- /Wizard Steps -->


					<div class="form-tab" id="formtab1">

            <!-- Company Information Fieldset -->
            <fieldset class="form-part1 current">
              <legend>Company Information</legend>
              <dl class="sections">
                <dt><?php echo $form['company_name']->renderLabel() ?></dt>
                <dd><?php echo $form['company_name']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['business_address']->renderLabel() ?></dt>
                <dd><?php echo $form['business_address']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['business_brgy_municipality_town']->renderLabel() ?></dt>
                <dd><?php echo $form['business_brgy_municipality_town']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['business_city_province']->renderLabel() ?></dt>
                <dd><?php echo $form['business_city_province']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['business_postal_code_zip_code']->renderLabel() ?></dt>
                <dd><?php echo $form['business_postal_code_zip_code']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['number_of_employees']->renderLabel() ?></dt>
                <dd><?php echo $form['number_of_employees']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['nature_of_business']->renderLabel() ?></dt>
                <dd><?php echo $form['nature_of_business']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['latest_ranking_of_company']->renderLabel() ?></dt>
                <dd><?php echo $form['latest_ranking_of_company']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['sector']->renderLabel() ?></dt>
                <dd><?php echo $form['sector']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['number_of_lines_applied_for']->renderLabel() ?></dt>
                <dd><?php echo $form['number_of_lines_applied_for']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <hr />
              <dl class="sections">
                <dt><?php echo $form['authorized_corporate_officer_signatory1']->renderLabel() ?></dt>
                <dd><?php echo $form['authorized_corporate_officer_signatory1']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['authorized_corporate_officer_signatory1_position']->renderLabel() ?></dt>
                <dd><?php echo $form['authorized_corporate_officer_signatory1_position']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['authorized_corporate_officer_signatory1_contact_number']->renderLabel() ?></dt>
                <dd><?php echo $form['authorized_corporate_officer_signatory1_contact_number']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['authorized_corporate_officer_signatory1_email_address']->renderLabel() ?></dt>
                <dd><?php echo $form['authorized_corporate_officer_signatory1_email_address']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['authorized_corporate_officer_signatory2']->renderLabel() ?></dt>
                <dd><?php echo $form['authorized_corporate_officer_signatory2']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['authorized_corporate_officer_signatory2_position']->renderLabel() ?></dt>
                <dd><?php echo $form['authorized_corporate_officer_signatory2_position']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['authorized_corporate_officer_signatory2_contact_number']->renderLabel() ?></dt>
                <dd><?php echo $form['authorized_corporate_officer_signatory2_contact_number']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['authorized_corporate_officer_signatory2_email_address']->renderLabel() ?></dt>
                <dd><?php echo $form['authorized_corporate_officer_signatory2_email_address']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <hr />
              <dl class="sections">
                <dt><?php echo $form['after_sales_signatory_ies1']->renderLabel() ?></dt>
                <dd><?php echo $form['after_sales_signatory_ies1']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['after_sales_signatory_ies1_position']->renderLabel() ?></dt>
                <dd><?php echo $form['after_sales_signatory_ies1_position']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['after_sales_signatory_ies1_contact_number']->renderLabel() ?></dt>
                <dd><?php echo $form['after_sales_signatory_ies1_contact_number']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['after_sales_signatory_ies1_email_address']->renderLabel() ?></dt>
                <dd><?php echo $form['after_sales_signatory_ies1_email_address']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['authorized_corporate_officer_signatory3']->renderLabel() ?></dt>
                <dd><?php echo $form['authorized_corporate_officer_signatory3']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['authorized_corporate_officer_signatory3_position']->renderLabel() ?></dt>
                <dd><?php echo $form['authorized_corporate_officer_signatory3_position']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['authorized_corporate_officer_signatory3_contact_number']->renderLabel() ?></dt>
                <dd><?php echo $form['authorized_corporate_officer_signatory3_contact_number']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['authorized_corporate_officer_signatory3_email_address']->renderLabel() ?></dt>
                <dd><?php echo $form['authorized_corporate_officer_signatory3_email_address']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <hr />
              <dl class="sections">
                <dt><?php echo $form['vat']->renderLabel() ?></dt>
                <dd><?php echo $form['vat']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['vat_bir_certificate_account_number']->renderLabel() ?></dt>
                <dd><?php echo $form['vat_bir_certificate_account_number']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['oct']->renderLabel() ?></dt>
                <dd><?php echo $form['oct']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['oct_bir_certificate_account_number']->renderLabel() ?></dt>
                <dd><?php echo $form['oct_bir_certificate_account_number']->render() ?></dd>
              </dl>
              <div class="clear" style="height:20px"></div>
            </fieldset>
            <!-- /Personal Information Fieldset -->

            <!-- Billing Instructions Fieldset -->
            <fieldset class="form-part2" style="display:none">
              <legend>Billing Instructions</legend>
              <dl class="sections">
                <dt><?php echo $form['corporate_managed_bills_sent_to']->renderLabel() ?></dt>
                <dd><?php echo $form['corporate_managed_bills_sent_to']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['bill_recipient_company_name']->renderLabel() ?></dt>
                <dd><?php echo $form['bill_recipient_company_name']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['bill_recipient_attention']->renderLabel() ?></dt>
                <dd><?php echo $form['bill_recipient_attention']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['bill_recipient_unit_number_floor']->renderLabel() ?></dt>
                <dd><?php echo $form['bill_recipient_unit_number_floor']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['bill_recipient_department']->renderLabel() ?></dt>
                <dd><?php echo $form['bill_recipient_department']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['bill_recipient_building_street']->renderLabel() ?></dt>
                <dd><?php echo $form['bill_recipient_building_street']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <hr />
              <dl class="sections">
                <dt><?php echo $form['receive_bill_summary']->renderLabel() ?></dt>
                <dd><?php echo $form['receive_bill_summary']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['bill_soft_copy_to_email_address']->renderLabel() ?></dt>
                <dd><?php echo $form['bill_soft_copy_to_email_address']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['bill_hard_copy_to_business_address']->renderLabel() ?></dt>
                <dd><?php echo $form['bill_hard_copy_to_business_address']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['bill_summary_contact_name']->renderLabel() ?></dt>
                <dd><?php echo $form['bill_summary_contact_name']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['bill_summary_contact_number']->renderLabel() ?></dt>
                <dd><?php echo $form['bill_summary_contact_number']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['bill_summary_type']->renderLabel() ?></dt>
                <dd><?php echo $form['bill_summary_type']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department1']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department1']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department1_contact_name_number']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department1_contact_name_number']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department1_bill_cut_off']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department1_bill_cut_off']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department1_corporate_id']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department1_corporate_id']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department2']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department2']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department2_contact_name_number']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department2_contact_name_number']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department2_bill_cut_off']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department2_bill_cut_off']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department2_corporate_id']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department2_corporate_id']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department3']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department3']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department3_contact_name_number']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department3_contact_name_number']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department3_bill_cut_off']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department3_bill_cut_off']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department3_corporate_id']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department3_corporate_id']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department4']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department4']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department4_contact_name_number']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department4_contact_name_number']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department4_bill_cut_off']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department4_bill_cut_off']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department4_corporate_id']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department4_corporate_id']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department5']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department5']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department5_contact_name_number']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department5_contact_name_number']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department5_bill_cut_off']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department5_bill_cut_off']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['breakdown_department5_corporate_id']->renderLabel() ?></dt>
                <dd><?php echo $form['breakdown_department5_corporate_id']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['corporate_code']->renderLabel() ?></dt>
                <dd><?php echo $form['corporate_code']->render() ?></dd>
              </dl>
              <div class="clear" style="height:20px"></div>
            </fieldset>
            <!-- /Employment/Financial Information Fieldset -->

            <!-- Assignee List Fieldset -->
            <fieldset class="form-part3" style="display:none">
              <legend>Assignee List</legend>
              <p>
                <input id="addAssignee" type="button" class="blue" value="AddAssignee" />
              </p>
              <br />

              <?php if(!$form->getObject()->isNew()): ?>
	              <?php $count = 0; ?>
	              <?php $assignees = $form->getObject()->getAssignee(); ?>
	              <?php foreach ($assignees as $assignee): ?>
	              		<?php include_partial('addAssigneeEdit', array('assignee'=>$assignee, 'num'=>$count)) ?>
                    <?php $count++ ?>
	              <?php endforeach; ?>
              <?php endif ?>

              <?php //include_partial('assigneeForm', array('assigneeNumber'=>'1')) ?>
            </fieldset>
            <!-- /Bill and Service Information Fieldset -->

            <!-- Bulk Service Application Fieldset -->
            <fieldset class="form-part4" style="display:none">
              <legend>Bulk Service Application (optional)</legend>
              <dl class="sections">
                <dt><?php echo $form['bulk_service']->renderLabel() ?></dt>
                <dd><?php echo $form['bulk_service']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['max_authorized_recipients']->renderLabel() ?></dt>
                <dd><?php echo $form['max_authorized_recipients']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['distribution_type']->renderLabel() ?></dt>
                <dd><?php echo $form['distribution_type']->render() ?></dd>
              </dl>
              <div class="clear"></div>
              <dl class="sections">
                <dt><?php echo $form['nominated_postpaid_charging_account']->renderLabel() ?></dt>
                <dd><?php echo $form['nominated_postpaid_charging_account']->render() ?></dd>
              </dl>
              <dl class="sections">
                <dt><?php echo $form['corporate_id']->renderLabel() ?></dt>
                <dd><?php echo $form['corporate_id']->render() ?></dd>
              </dl>
              <div class="clear" style="height:20px"></div>
            </fieldset>
            <!-- /Bulk Service Application Fieldset -->

					</div>
					<!-- /Side Tab Content #sidetab1 -->

				</div>

    <input id="submitUser" style="float: right; display:none;" type="button" class="blue small" value="Submit" />
    <input id="nextStep" style="float: right;" type="button" class="blue small" value="Next - Billing Instructions" />
    <input id="cancelUser" type="button" class="blue small" value="Back" />

</form>

<script type="text/javascript">
$(document).ready(function(){

    // initialize step
    var step = 1;

    // function to hide/show dependent fields
    showHideFields = function(elements) {
      if(elements === undefined) {
        elements = $('.dependent');
      }
      $.each(elements, function() {
        switch($(this).attr('data-dependent')) {

          // check for dependent fields of bill_summary_type
          case 'application_corporate_managed_bill_summary_type':
            if($('#'+$(this).attr('data-dependent')).val() != 'BREAKDOWN PER DEPARTMENT') {
              $(this).val('');
              $(this).parents('dl').slideUp('normal',function() {
                $('label[for="'+$(this).attr('id')+'"]').parents('dl').slideUp();
              });
            }
            else {
              $(this).parents('dl').slideDown('normal',function() {
                $('label[for="'+$(this).attr('id')+'"]').parents('dl').slideDown();
              });
            }
            break;
          // check for dependent fields of corporate_managed_bills_sent_to
          case 'application_corporate_managed_corporate_managed_bills_sent_to':
            if($('#'+$(this).attr('data-dependent')).val() != 'ONE RECIPIENT') {
              $(this).val('');
              $(this).parents('dl').slideUp('normal',function() {
                $('label[for="'+$(this).attr('id')+'"]').parents('dl').slideUp();
              });
            }
            else {
              $(this).parents('dl').slideDown('normal',function() {
                $('label[for="'+$(this).attr('id')+'"]').parents('dl').slideDown();
              });
            }
            break;
          // check for dependent fields of vat
          case 'application_corporate_managed_vat':
            if(!$('#'+$(this).attr('data-dependent')).is(':checked')) {
              $(this).val('');
              $(this).parents('dl').slideUp('normal',function() {
                $('label[for="'+$(this).attr('id')+'"]').parents('dl').slideUp();
              });
            }
            else {
              $(this).parents('dl').slideDown('normal',function() {
                $('label[for="'+$(this).attr('id')+'"]').parents('dl').slideDown();
              });
            }
            break;
          // check for dependent fields of oct
          case 'application_corporate_managed_oct':
            if(!$('#'+$(this).attr('data-dependent')).is(':checked')) {
              $(this).val('');
              $(this).parents('dl').slideUp('normal',function() {
                $('label[for="'+$(this).attr('id')+'"]').parents('dl').slideUp();
              });
            }
            else {
              $(this).parents('dl').slideDown('normal',function() {
                $('label[for="'+$(this).attr('id')+'"]').parents('dl').slideDown();
              });
            }
            break;
          // check for dependent fields of receive_bill_summary
          case 'application_corporate_managed_receive_bill_summary':
            if(!$('#'+$(this).attr('data-dependent')).is(':checked')) {
              $(this).val('');
              $(this).parents('dl').slideUp('normal',function() {
                $('label[for="'+$(this).attr('id')+'"]').parents('dl').slideUp();
              });
            }
            else {
              $(this).parents('dl').slideDown('normal',function() {
                $('label[for="'+$(this).attr('id')+'"]').parents('dl').slideDown();
              });
            }
            break;
        }





      });

    }

    showHideFields();


    // attach showHideFields to change events
    $('#application_corporate_managed_vat').change(function() {
      showHideFields();
    });
    $('#application_corporate_managed_oct').change(function() {
      showHideFields();
    });
    $('#application_corporate_managed_receive_bill_summary').change(function() {
      showHideFields();
    });
    $('#application_corporate_managed_bill_summary_type').change(function() {
      showHideFields();
    });
    $('#application_corporate_managed_corporate_managed_bills_sent_to').change(function() {
      showHideFields();
    });



    $("#frmUser").validationEngine();

    $('.form-tabs li a').click(function() {
      var parentIndex = $(this).parent().index();
      var proceed = false;
      if((parseInt(parentIndex)+1) > step) {
        if(jQuery("#frmUser").validationEngine('validate')) {
          proceed = true;
        }
      }
      else {
        proceed = true;
      }

      if(proceed) {
        $('div.formError').remove();
        var thisID = $(this).attr('id');
        if(thisID != $('nav#form-tab ul li a.current').attr('id')) {

          $('.form-tabs ol li a.current').removeClass('current');
          $('#frmUser fieldset.current').fadeOut('slow',function() {
            $(this).removeClass('current');
            $('fieldset.'+thisID).fadeIn('slow',function() {
              $('.form-tabs ol li a#'+thisID+', fieldset.'+thisID).addClass('current');
              step = parseInt(parentIndex)+1;

              if(thisID == 'form-part4') {
                $('#nextStep').hide();
                $('#submitUser').show();
              }
              else {
                var nextStepTitle = $('.form-tabs li a:eq('+step+')').html();
                $('#nextStep').val('Next - '+nextStepTitle);
                $('#nextStep').show();
                $('#submitUser').hide();
              }
              showHideFields();
            });
          });
        }

      }

    });

    $("#submitUser").click(function(){

      if(jQuery("#frmUser").validationEngine('validate')) {
        toggleLoading();
        dataAr = $("#frmUser").serializeArray();
        $.ajax({
            url: '<?php echo ($form->getObject()->isNew()) ? url_for('corporatemanaged/ajaxSave') : url_for('corporatemanaged/update').'?id='.$form->getObject()->getId()  ?>',
            type: 'POST',
            dataType: 'json',
            data: dataAr,
            success: function(response){
              $("#notification").empty();
              if(response.valid == 'false') {
                $("#notification").show();
                var errors = response.message.split('|');
                $.each(errors, function(index, value) {
                  $('#notification').append('<p>'+ this + '</p>');
                });
                var colonPos = errors[0].indexOf(':');
                var firstErrorField = errors[0].substring(0,colonPos);

                $.each($('ol.wizard-steps li a'), function(index, value) {
                  if($('.'+$(this).attr('id')+' #application_corporate_managed_'+firstErrorField).length > 0) {
                    $(this).click();
                  }
                });
              }
              else {
                $("#notification").html(response.message);
                $("#tab2-content").empty();
                $("#crud_data").click();
                jQuery("#frmUser").validationEngine('validate');
              }
              toggleLoading();
            }

        });
      }
      else {
        return false;
      }
    });

    $("#cancelUser").click(function(){
      if(step != 1) {
        $('.form-tabs li a:eq('+(parseInt(step)-2)+')').click();
      }
      else {
        $("#tab2-content").empty();
        $('div.formError').remove();
        $("#crud_data").click();
      }
    });

    $('#nextStep').click(function() {
      $('.form-tabs li a:eq('+(parseInt(step))+')').click();
    });

//    var assignees = 1;
//
//    $('#addAssignee').click(function() {
//      assignees+=1;
//      toggleLoading();
//      $.ajax({
//        url: '<?php echo url_for('corporatemanaged/addAssignee') ?>?assigneenumber='+assignees,
//        success: function(response) {
//          $('.form-part3').append(response);
//          toggleLoading();
//        }
//      });
//    });

    var assignee = <?php print_r($form['assignees']->count())?>;

    $('#addAssignee').click(function() {
         toggleLoading();
         $.ajax({
                url: '<?php echo url_for('corporatemanaged/addAssigneeForm')?>'+
                		 '<?php echo   ($form->getObject()->isNew()?'':'?id='.$form->getObject()->getId()).
                		 							 ($form->getObject()->isNew()?'?num=':'&num=')?>'+assignee,
                type: 'GET',
                cache: false,
                //success
                success: function (data) {
                    $('.form-part3').append(data);
                    toggleLoading();
                    assignee = assignee + 1;
                }
            });
            return false;
    });


});
</script>